<?php

$sql="select * from slideshow order by id desc limit 0,3";
$slideshow_rows=selectAll($sql);

$sql="select * from other";
$other_row=selectOne($sql);

$sql="select * from pro_cate";
$pro_rows=selectAll($sql);
$pro_id=isset($_GET['pro_id'])?$_GET['pro_id']:$pro_rows[0]['id'];
$sql="select * from pro_cate where id=$pro_id";
$pro_row=selectOne($sql);

    $p=isset($_GET['p'])?$_GET['p']:1;
	$pagesize=9;
	$index=($p-1)*$pagesize;
	$sql="select * from product where cateid=$pro_id order by id desc limit $index,$pagesize";
    $pro_cate=selectAll($sql);
    if(!$pro_cate){
       show("该分类无内容！",'index.php?m=home&c=product&#product');
     }

	$sql="select count(id) from product where cateid=$pro_id";
	$row=selectOne($sql);
    $count=$row[0];
    $pages=ceil($count/$pagesize);
    $prepage = $p-1;
    $nextpage = $p+1;
    $str="<ul>";
    if($p>1){
    	$str.="<li ><a href='index.php?m=home&c=product&p=$prepage&#product'>上一页</a></li>";
    }else{
    	$str.="<li ><a href='javascript:;'>上一页</a></li>";
    }
    for($i=$p-2;$i<=$p-1;$i++){
    	if($i>0){
    		$str.="<li><a href='index.php?m=home&c=product&p=$i&#product'>$i</a></li>";
    	}
    }
    $str.="<li><a href='javascript:void(0)' class='on'>$p</a></li>";
    for($i=$p+1;$i<=$p+2;$i++){
    	if($i<$pages){
    		$str.="<li><a href='index.php?m=home&c=product&p=$i&#product'>$i</a></li>";
    	}
    }
    if($p<$pages){
    	$str.="<li ><a href='index.php?m=home&c=product&p=$nextpage&#product'>下一页</a></li>";
    }else{
    	$str.="<li ><a href='javascript:;'>下一页</a></li>";
    }
    $str.="</ul>";


include './html/home/product.html';

?>